package com.hmall.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hmall.user.pojo.Address;
import com.hmall.user.pojo.User;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 操作用户
 */
@Repository
public interface UserMapper extends BaseMapper<User> {
    /**
     * 根据用户id查询地址列表
     * @param uid
     * @return
     */
    @Select("select * from tb_address where user_id=#{uid}")
    List<Address> findAddress(Long uid);

    /**
     * 根据地址id查询地址
     * @param id 地址id
     * @return 返回地址对象
     */
    @Select("select * from tb_address where id=#{id}")
    Address findAddresses(Long id);

    @Select("select * from tb_user where id=#{userId}")
    User findUserId(Long userId);
}
